#ifndef THREAD_SEARCH_LOGGER_LIST_H
#define THREAD_SEARCH_LOGGER_LIST_H

#include <wx/event.h>

#include "ThreadSearchLoggerBase.h"

class wxPanel;
class wxWindow;
class wxListEvent;
class wxListCtrl;
class wxString;

class ThreadSearch;
class ThreadSearchView;
class ThreadSearchEvent;

class ThreadSearchLoggerList : public wxEvtHandler, public ThreadSearchLoggerBase {
  public:

    ThreadSearchLoggerList( ThreadSearchView& threadSearchView, ThreadSearch& threadSearchPlugin,
                            InsertIndexManager::eFileSorting fileSorting, wxPanel* pParent, long id );


    virtual ~ThreadSearchLoggerList();


    virtual eLoggerTypes GetLoggerType() {return TypeList;}


    virtual void Update();


    virtual void OnThreadSearchEvent( const ThreadSearchEvent& event );


    virtual void Clear();


    virtual void OnSearchBegin( const ThreadSearchFindData& findData );

    virtual void OnSearchEnd();


    virtual wxWindow* GetWindow();


    virtual void SetFocus();


    void OnLoggerListClick( wxListEvent& event );


    void OnLoggerListDoubleClick( wxListEvent& event );


    void OnColumnClick( wxListEvent& event );
  protected:

    void SetListColumns();


    bool GetFileLineFromListEvent( wxListEvent& event, wxString& filepath, long &line );


    bool IsLineResultLine( long index = -1 );


    virtual void ConnectEvents( wxEvtHandler* pEvtHandler );


    virtual void DisconnectEvents( wxEvtHandler* pEvtHandler );


    void OnLoggerListContextualMenu( wxContextMenuEvent& event );


    void OnDeleteListItem( wxCommandEvent& event );


    void OnDeleteAllListItems( wxCommandEvent& event );


    void DeleteListItem( long index );


    void DeleteListItems();

  private:
    wxListCtrl* m_pListLog;
    long        m_IndexOffset;
    size_t      m_TotalLinesFound; // Count the number of found lines/matches
    int         m_SortColumn;
    bool        m_Ascending;
    bool        m_MadeVisible;
};

#endif
